<?php
/**
 * Remove a contact from a Mission.
 * Interface
 * 
 * @author Xavier VILAIN
 * @package Hive\Mission
 * 
 */
use Hive\Mission;

$xview = Xview::instance();
$partnerid = $xview->val('partnerid');
$role = $xview->val('role');
$mid = $xview->val('missionid');
/* @var $contact Hive\Mission */
$mission = $xview->component("missions", "object");// Load Mission

if(!empty($mission)) {
// Remove Contact 
	try {
		$partner = $mission->findPartners("$mid:$role:$partnerid");
		if($partner->exists()) {
			$mission->deleteFromPartners($partner);
			$mission->prepareUpdate(Mission::CHANGE_PARTNER_REMOVE);
			$mission->update();
		}
		Fox\Message::Success(Msg(Hive::BUNDLE,Hive::MISSION_REMOVE_PARTNER,$partner->contact()->name(),$mission->label()));
		
	} catch (Fox\Object\Exception\Save $e) {
		Fox\Message::Error($e);
	}

} else {
	// Should not be possible to reach this
	
}
echo $xview->messages();